﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using IDAL.RF.ATETest;
using Model;

namespace DAL.RF.ATETest
{
    public class TestItem_Active : BaseRepository<TestItemInfo>, ITestItem_Active
    {
        #region 静态变量定义部分
        private const string PARM_TESTITEM_PRODUCTSN = "@ProductSN";
        private const string PARM_TESTITEM_TESTTIME = "@TestTime";
        #endregion

        #region 数据检索部分
        public IList<TestItemInfo> TestItem_Active_GetbySNDT(string productSN, DateTime testTime)
        {
            //Create a parameter    
            SqlParameter[] Parms = GetSNDTParameters();
            //Bind the parameter
            Parms[0].Value = productSN;
            Parms[1].Value = testTime;
            return ExcuteSqlToGetEntities("TestItem_Active_selectbySNDT", Parms);
        }
        #endregion

        #region 参数部分
        private static SqlParameter[] GetSNDTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_TESTITEM_PRODUCTSN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_TESTITEM_TESTTIME, SqlDbType.DateTime, 8)                
                };
            return parms;
        }
        #endregion


        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override TestItemInfo GetEntityRecord(SqlDataReader rdr)
        {
            TestItemInfo pro = new TestItemInfo(rdr.GetGuid(0), rdr.GetValue(1).ToString(), rdr.GetValue(2).ToString(), rdr.GetDateTime(3), rdr.GetInt32(4), 
                rdr.GetDecimal(5), rdr.GetDecimal(6), rdr.GetDecimal(7), rdr.GetDecimal(8), rdr.GetDecimal(9), rdr.GetDecimal(10), rdr.GetValue(11).ToString(), 
                rdr.GetValue(12).ToString());
            return pro;
        }
        #endregion
    }
}
